package com.qiu.usercenter.common;


/**
 * 返回工具类
 *
 * @author qiu
 */
public class ResultUtils {
    // 成功返回
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<T>(0, data, "ok", "");
    }

    // 失败返回
    public static <T> BaseResponse<T> error(ErrorCode errorCode) {
        return new BaseResponse<T>(errorCode);
    }

    // 失败返回
    public static <T> BaseResponse<T> error(ErrorCode errorCode, String description) {
        return new BaseResponse<T>(errorCode, description);
    }

    // 失败返回
    public static <T> BaseResponse<T> error(ErrorCode errorCode, String message, String description) {
        return new BaseResponse<T>(errorCode, message, description);
    }

    // 失败返回
    public static <T> BaseResponse<T> error(int code, String message, String description) {
        return new BaseResponse<T>(code, null, message, description);
    }
}
